﻿using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using YJM.ModbusMonitor.GUI.Views;

namespace YJM.ModbusMonitor.GUI.Core
{
    public static class AFContainer
    {
        public static IContainer instance { get; set; }
        private static ContainerBuilder builder = new ContainerBuilder();

        static AFContainer()
        {
            builder.RegisterType<DataMonitorView>().AsSelf().As<UserControl>()
              .Named<UserControl>("DataMonitorView").SingleInstance();
            builder.RegisterType<HistoryDataView>().AsSelf().As<UserControl>()
              .Named<UserControl>("HistoryDataView").SingleInstance();
            builder.RegisterType<ConfigureView>().AsSelf().As<UserControl>()
              .Named<UserControl>("ConfigureView").SingleInstance();
        }

        public static IContainer getInstance()
        {
            if (instance == null)
            {
                instance = builder.Build();
            }
            return instance;
        }
    }
}
